<template>
	<view>
		<view class="sbox dfx">
			<view class="sort mr20" :class="[idx==index && 'active']" v-for="(item,idx) in list" :key="idx"
				@click="$emit('choose', idx)">
				{{item.name||item}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "tabs",
		props: {
			tabs: {
				type: Array,
				default: []
			},
		},
		data() {
			return {
				list: [],
				index: 0,
			};
		},
		watch: {
			tabs: {
				handler(newVal) {
					console.log('cutt', newVal);
					if (newVal.length > 0) {
						this.list = newVal
						this.$forceUpdate()
					}
				},
				immediate: true
			}
		},
		methods: {
			choose(idx) {}
		}
	}
</script>

<style lang="scss">
	.sbox {
		margin-bottom: 24rpx;

		.sort {
			border-radius: 32rpx;
			color: #8fbaff;
			background: #eef5ff;
			width: 130rpx;
			height: 50rpx;
			line-height: 50rpx;
			text-align: center;
			font-size: 14px;
		}

		.active {
			background: #146fff;
			color: #fff;
		}
	}
</style>